home *** CD-ROM | disk | FTP | other *** search
/ APDL Eductation Resources / APDL Eductation Resources.iso / earthmap / _earthmap / maps / getpar / c / fsize < prev    next >
Encoding:
Text File  |  1989-04-01  |  530 b   |  22 lines

  1. /* This routine finds the length of a file and returns its size in number
  2. of bytes. filedes is the file descriptor that is returned by a open()
  3. command or a creat() command. */
  4. #include    <sys/types.h>
  5. #include    <sys/stat.h>
  6.  
  7. int
  8. fsize (filedes)
  9.     int             filedes;
  10. /*
  11.  *    returns size of file in bytes
  12.  *
  13.  * modified 1/26/83  S. Levin corrected length and simplfied
  14.  * modified 3/27/83  return -1 if fstat fails.
  15.  */
  16. {
  17. struct stat     buf;
  18.     if (0 != fstat (filedes, &buf))
  19.     return (-1);
  20.     return ((int) buf.st_size);
  21. }
  22.